
function ShowHide_Box(target, forced) {
	var element = v$('moreinfo_' + target);
	var box = v$('moreinfobox_' + target);

	var img = element.getElementsByTagName('img')[0];
	var visible = ShowHide(box, forced);
	if (!img) {
		return;
	}
	if (box == null) {
		visible = forced;
	}
	Flip_Arrow(img, visible);
}

function ShowHide_Box2(target, forced) {
	var element = v$('moreinfo_' + target);
	var box = 'moreinfobox_' + target;

	var img = element.getElementsByTagName('img')[0];
	var visible;

	if ($('#' + box).is(":visible")) {
		visible = false;
	}
	else {
		visible = true;
	}

	$('#' + box).slideToggle(600);
	Flip_Arrow(img, visible);
}

function Flip_Arrow(img, forced) {
	var newClassName, oldClassName, origClassName;
	origClassName = img.className;
	
	oldClassName = (origClassName.indexOf('up_arrow_img') == -1) ? 'down_arrow_img' : 'up_arrow_img';
	
	if (forced === true) {
		newClassName = 'up_arrow_img';
	}
	else if (forced === false) {
		newClassName = 'down_arrow_img';
	}
	else if (oldClassName == 'up_arrow_img') {
		newClassName = 'down_arrow_img';
	}
	else if (oldClassName == 'down_arrow_img') {
		newClassName = 'up_arrow_img';
	}
	img.className = origClassName.replace(oldClassName, newClassName);
}

function fadeNavigationMenu(show) {
	if (show) {
		fadeNavigationMenuComplete('mainmenu', true);
		vfade('mainmenu', true, 0.4, fadeNavigationMenuComplete, false);
	}
	else {
		vfade('mainmenu', false, 0.4, fadeNavigationMenuComplete, true);
	}
}
function fadeNavigationMenuComplete(element, show) {
	if (show) {
		document.getElementsByTagName('html')[0].id = '';
		v$("mainmenusmall").style.display='none';
	}
	else {
		document.getElementsByTagName('html')[0].id = 'nav_hidden';
		v$("mainmenusmall").style.display='block';
	}
	qew_ie6_resize();
}

function perform_cancel(pobj){
	
	var arr = new Array();
	
	arr.push(v$(pobj).getElementsByTagName('input'));
	arr.push(v$(pobj).getElementsByTagName('select'));
	arr.push(v$(pobj).getElementsByTagName('textarea'));
	
	for(var i=0; i<arr.length; i++){
		for(var x=0;x<arr[i].length;x++){
			switch(arr[i][x].type){
				case "text":
					//alert("found a text box will empty");
					arr[i][x].value="";
					break;
				case "textarea":
					//alert("found a text box will empty");
					arr[i][x].value="";
					break;
				case "radio":
					//alert("found a radio will empty!");
					arr[i][x].checked = false;
					break;
				case "checkbox":
					//alert("found a checkbox will empty");
					arr[i][x].checked = false;
					break;
				case "select-one":
					//alert("found a select-one will empty");
					arr[i][x].selectedIndex = 0;
					break;
				default:
					//some other NEW kind of input type - probably a button or imagebutton
					break;
			}
		}
	}
}


function alt_call_attention(modifier,iterator,toggle,modus,stylemod){
	if(!stylemod){
		stylemod = '';
	}
	var elementId = modifier+iterator;
	//alert(toggle + ":" + elementId);
	if(toggle)
	{
		if(v$(elementId+"a"))
			{
			v$(elementId+"a").style.backgroundColor = "auto";
			v$(elementId+"a").bgColor = "#ececec";
			}
		if(v$(elementId+"b"))
			{
			v$(elementId+"b").style.backgroundColor = "auto";
			v$(elementId+"b").bgColor = "#ececec";
			}
		if(v$(elementId+"c"))
			{
			v$(elementId+"c").style.backgroundColor = "auto";
			v$(elementId+"c").bgColor = "#ececec";
			}
		if(v$(elementId+"d"))
			{
			v$(elementId+"d").style.backgroundColor = "auto";
			v$(elementId+"d").bgColor = "#ececec";			
			}

			//document.getElementById(elementId+'b').bgColor = '#ececec';
//			document.getElementById(elementId+'a').style.backgroundColor = '#ececec';
//			document.getElementById(elementId+'b').style.backgroundColor = '#ececec';
			/*
			//uniquetoggleme(elementId+'');
			uniquetoggleme(elementId+'a', false);
			//uniquetoggleme(elementId+'b', false);
			*/
	}
	else {
		
		if(v$(elementId+"a"))
			{
			v$(elementId+"a").style.backgroundColor = "auto";
			v$(elementId+"a").bgColor = "#ffffff";
			}
		if(v$(elementId+"b"))
			{
			v$(elementId+"b").style.backgroundColor = "auto";
			v$(elementId+"b").bgColor = "#ffffff";
			}
		if(v$(elementId+"c"))
			{
			v$(elementId+"c").style.backgroundColor = "auto";
			v$(elementId+"c").bgColor = "#ffffff";
			}
		if(v$(elementId+"d"))
			{
			v$(elementId+"d").style.backgroundColor = "auto";
			v$(elementId+"d").bgColor = "#ffffff";			
			}		
	//document.getElementById(elementId+'b').bgColor = '';
//			document.getElementById(elementId+'a').style.backgroundColor = '';
//			document.getElementById(elementId+'b').style.backgroundColor = '';
			/*
			if(modus==0)
			{
				//uniquetoggleme(elementId+'', stylemod+'one');
				uniquetoggleme(elementId+'a', true);
				//uniquetoggleme(elementId+'b', true);
			}else{
				//uniquetoggleme(elementId+'', stylemod+'two');
				uniquetoggleme(elementId+'a', true);
				//uniquetoggleme(elementId+'b', true);
			}*/
		/*
		case true:
			if(v$(modifier+iterator+''))v$(modifier+iterator+'').className+=' hover';
			if(v$(modifier+iterator+'a'))v$(modifier+iterator+'a').className+=' hover';
			if(v$(modifier+iterator+'b'))v$(modifier+iterator+'b').className+=' hover';
			break;
		case false:
		
			if(modus==0)
			{
				if(v$(modifier+iterator+''))v$(modifier+iterator+'').className=stylemod+'one';
				if(v$(modifier+iterator+'a'))v$(modifier+iterator+'a').className=stylemod+'one';
				if(v$(modifier+iterator+'b'))v$(modifier+iterator+'b').className=stylemod+'one';
			}else{
				if(v$(modifier+iterator+''))v$(modifier+iterator+'').className=stylemod+'two';
				if(v$(modifier+iterator+'a'))v$(modifier+iterator+'a').className=stylemod+'two';
				if(v$(modifier+iterator+'b'))v$(modifier+iterator+'b').className=stylemod+'two';
			}
			break;
		*/
	}

}

function highlightRows(modifier,iterator,toggle,defaultColor,highlightColor){
	
	var elementId = modifier+iterator;
	
	if(toggle)
	{
		if(v$(elementId+"a"))
			{
			v$(elementId+"a").bgColor = highlightColor;
			}
		if(v$(elementId+"b"))
			{
			v$(elementId+"b").bgColor = highlightColor;
			}
		if(v$(elementId+"aa"))
			{
			v$(elementId+"aa").bgColor = highlightColor;
			}
		if(v$(elementId+"bb"))
			{
			v$(elementId+"bb").bgColor = highlightColor;
			}
		if(v$(elementId+"c"))
			{
			v$(elementId+"c").bgColor = highlightColor;
			}
		if(v$(elementId+"d"))
			{
			v$(elementId+"d").bgColor = highlightColor;			
			}

	}
	else {
		
		if(v$(elementId+"a"))
			{
			v$(elementId+"a").bgColor = defaultColor;
			}
		if(v$(elementId+"b"))
			{
			v$(elementId+"b").bgColor = defaultColor;
			}
		if(v$(elementId+"aa"))
			{
			v$(elementId+"aa").bgColor = defaultColor;
			}
		if(v$(elementId+"bb"))
			{
			v$(elementId+"bb").bgColor = defaultColor;
			}
		if(v$(elementId+"c"))
			{
			v$(elementId+"c").bgColor = defaultColor;
			}
		if(v$(elementId+"d"))
			{
			v$(elementId+"d").bgColor = defaultColor;			
			}		
	}

}

// rss
function rssOnLoad(id)
{
	v$('rss-feed-loading-' + id).style.display = 'none';
	v$('rss-feed-' + id).className = '';
}
// rss


//2010-06-08: 1124

function ValidateNumericRange(el, low, hi) {
	var val = el.value;
	newval = /\d+/.exec(val);
	if (!newval) { newval = ''; }
	if (low) {
		if (newval < low) { newval = low; }
	}
	if (hi) {
		if (newval > hi) { newval = hi; }
	}
	if (/\d+/.test(newval)) { newval *= 1; }
	el.value = newval;
}

//2010-06-16: 768

//Enter Key const
var ENTER_KEY = 13;

function IESubmitFormOnEnter() {
	if (!/Internet Explorer/gi.test(navigator.appName)) {
		return;
	}
	if (!window.event) {
		return;
	}
	var keycode = window.event.keyCode;
	if (keycode != ENTER_KEY) {
		return; 
	}
	var el = window.event.srcElement;
	if (!el) {
		return;
	}
	var f = el.form;
	if (!f) {
		return;
	}
	for (var i = 0; i < f.elements.length; i++) {
		var el = f.elements[i];
		if (el.type && el.type == 'submit') {
			el.click();
			return;
		}
	}
}
function processChanges(button) {
	var DeleteMarks = numberOfDeletions();
	if (DeleteMarks > 0) {
		//Show confirm modal, not browser confirm, but our modal-ish confirm
		var WarningText = "Are you sure you want to delete " ;
		WarningText = (DeleteMarks > 1) ? WarningText + "these " + DeleteMarks + " records?" : WarningText + "this 1 record?"
		$("#DeleteConfirmationText").html(WarningText);
		toggleOverlay('confirm_delete', true);
	}
	else {
		//We all good.  Submit the form.
		v$(button).click();
	}
}
function numberOfDeletions() {
	var records_to_delete = 0

	jQuery("form input:checkbox").each(function () {
		if (jQuery(this).attr("id") == "DELETE") {
			if (jQuery(this).is(':checked')) {
				records_to_delete = records_to_delete + 1;
			}
		}

	});
	
	return records_to_delete;
}